import React, { useState } from 'react';
import store from '@/stores/redux';
import { Button } from 'antd';
import { setCount } from '@/stores/redux/modules/userInfo.ts';

const Login = () => {
	const [count, setCountVal] = useState<number>(0);
	// console.log('store', store);
	// console.log('store.getState()', store.getState());
	// console.log('store.getState()', store.getState().count);
	// 状态数据发生改变
	store.subscribe(() => {
		const store_data = store.getState().Info;
		setCountVal(store_data.count);
	});
	const countStoreSet = async () => {
		const val = 1 + count;
		// console.log('val', val);
		// store.dispatch({ type: 'SET_COUNT', count: val });
		const res = await setCount(val);
		console.log('res', res);
	};
	return (
		<div>
			<div>
				{count}=={store.getState().Info.count}
			</div>
			<div>登录页</div>
			<Button onClick={countStoreSet}>设置值</Button>
		</div>
	);
};

export default React.memo(Login);
